package com.shsxt.crm.controller.customer;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.shsxt.crm.model.YgCustomerLoss;
import com.shsxt.crm.service.ICustomerLossService;
import com.shsxt.framework.context.BaseController;

@Controller
@RequestMapping("/customer_loss")
public class CustomerLossController extends BaseController {

	@Autowired
	private ICustomerLossService customerLossService;

	@GetMapping("index.shtml")
	public String index() {
		return "customer_loss";
	}

	/**
	 * 查询 流失客户
	 * 
	 * @return
	 */
	@PostMapping("/queryCustomerLossesByParams")
	@ResponseBody
	public Map<String, Object> queryCustomerLossesByParams(YgCustomerLoss ygCustomerLoss) {
		return customerLossService.queryCustomerLossesByParams(ygCustomerLoss);
	}

	@GetMapping("/{lossId}/customerRepriPage")
	public ModelAndView customerRepriPage(@PathVariable("lossId") Integer lossId) {
		ModelAndView mv = new ModelAndView();
		YgCustomerLoss customerLoss = customerLossService.queryCustomerLossById(lossId);
		mv.setViewName("customer_repri");
		mv.addObject("customerLoss", customerLoss);
		return mv;
	}
}
